﻿#pragma once
#include "FCMiddleware_global.h"
#include <QObject>
#include <QString>
#include <QTcpSocket>

namespace FCMiddleware
{
    class FCMIDDLEWARE_EXPORT TcpClient : public QObject
	{
		Q_OBJECT

	public:
		TcpClient(QObject *parent = nullptr);
		TcpClient(const QString& hostName, unsigned short hostPort, QObject *parent = nullptr);
		~TcpClient();

	protected:
		QTcpSocket* _tcpClient;
		QString _hostName;
		unsigned short _hostPort;

	public:
		bool connectToServer(unsigned int overtime, int* err);
        void destory();

        virtual int recv(unsigned char* recvBuf, unsigned int size, int* err);
        virtual int send(char* sendBuf, unsigned int size, int* err);
	};
}

